// ActionScript file

package org.sepy
{
	import com.adobe.webapis.flickr.License;
	import com.adobe.webapis.flickr.User;
	import com.adobe.webapis.flickr.Photo;
	import com.adobe.webapis.flickr.PhotoTag;
	
	public class Utils
	{
		
		public static var static_url:String = "http://farm1.static.flickr.com/";
					
		public static function getLicenseName(l:License):String
		{
			switch(l.id)
			{
				case License.ATTRIBUTION:
					return "Attribution License";
					break;
				case License.ATTRIBUTION_NODERIVS:
					return "Attribution-NoDerivs License";
					break;
				case License.ATTRIBUTION_NONCOMMERCIAL:
					return "Attribution-NonCommercial License";
					break;
				case License.ATTRIBUTION_NONCOMMERCIAL_NODERIVS:
					return "Attribution-NonCommercial-NoDerivs Licens";
					break;
				case License.ATTRIBUTION_NONCOMMERCIAL_SHAREALIKE:
					return "Attribution-NonCommercial-ShareAlike License";
					break;
				case License.ATTRIBUTION_SHAREALIKE:
					return "Attribution-NonCommercial-ShareAlike License";
					break;
				default:
					return "All Rights Reserved";
					break;
			}
			return "";
		}
		
		/**
		 * Return the image path string (mtsn)
		 */
		public static function getPhotoURL(photo:Photo, type:String = ""):String
		{
			if(type != "")
			{
				return Utils.static_url + photo.server + "/" + photo.id + "_" + photo.secret + "_" + type + ".jpg"
			} 
			else 
			{
				return Utils.static_url + photo.server + "/" + photo.id + "_" + photo.secret + ".jpg"
			}
		}
		
		/**
		 * Return the buddyicon image path
		 */
		public static function getBuddyIcon(user:User):String
		{
			if(user.iconServer > 0)
			{
				return Utils.static_url + user.iconServer + "/buddyicons/" + user.nsid + ".jpg";
			} 
			else 
			{
				return "http://www.flickr.com/images/buddyicon.jpg";
			}
		}
		
		
		public static function getMaxTag(a:Array):uint
		{
			var max:uint = 0;
			for each(var tag:PhotoTag in a)
			{
				if(tag.count > max)
				{
					max = tag.count;
				}
			}
			return max;
		}
	}
}